home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Genie / Projects / A-line / Scripts / Master.mk < prev    next >
Encoding:
Text File  |  2000-06-24  |  6.5 KB  |  194 lines

  1. # Generic Makefile for dmake
  2. #
  3. # Notes:
  4. #
  5. # The reason we have MOREINCDIRS and MOREINCDIRSR is because we need both, 
  6. # at least as long as we're using dmake.  The difference is that MOREINCDIRSR
  7. # has aliases resolved.  We need this for the .SOURCE special targets, which 
  8. # don't follow aliases (except in the case of a %-rule, in which case dmake 
  9. # *does* infer the rule, but then fails to set $< correctly.  But we also need
  10. # MOREINCDIRS, because it has no spaces in the pathnames.  Pathnames with spaces
  11. # are apparantly impossible to manipulate properly as entire tokens, as required
  12. # to append ' -i ' before each one.  (It's actually more complicated than this:  
  13. # They *are* treated as tokens, but only once.  And the -i step takes two 
  14. # modifications, so you're screwed.)
  15. # I'm sorry I came up with such a lame workaround, but I think it does the tool
  16. # justice.
  17. # Of course, now we pregenerate everything with Perl, so no more problem.
  18. # It's amazing what you can accomplish when you make your own tools,
  19. # and you have what to make them with.
  20.  
  21. .INCLUDE : "Include.mk"
  22.  
  23. MAKETARGET *= "unspecified target"
  24. #INCDIR *= Includes
  25. #SRCDIR *= Sources
  26. PROJLABDIR *= ":"
  27. DEPSDIRNAME *= [Dependencies]
  28. OBJDIRNAME *= (Objects)
  29. LIBDIRNAME *= (Libraries)
  30. EXEDIRNAME *= (Executables)
  31. COMPILER *= MW
  32. #COMPILER *= MrC
  33. #COMPILER *= SC
  34. ARCH *= PPC
  35. #ARCH *= 68K
  36. BUILD *= Debug
  37. CREATOR *= '????'
  38.  
  39. QQ = "
  40. ALLSRCS = $(SRCS) $(MORESRCS)
  41. OBJS-MW = $(SRCS:b:+".o")
  42. OBJS-SC = $(SRCS:+".o")
  43. #OBJS = $(OBJS-$(COMPILER))
  44. OBJS = $(SRCS:b:+".o")
  45. MOREOBJS-MW = $(MORESRCS:b:+".o")
  46. MOREOBJS-SC = $(MORESRCS:+".o")
  47. #MOREOBJS = $(MOREOBJS-$(COMPILER))
  48. MOREOBJS = $(MORESRCS:b:+".o")
  49. OBJDIR = $(PROJLABDIR)$(OBJDIRNAME):$(ARCH):$(COMPILER):$(BUILD):
  50. ALLOBJS = $(OBJS:^$(OBJDIR)) $(MOREOBJS:^$(OBJDIR)) $(EXTRAOBJS)
  51. #ALLLIBS = $(LIBS) $(SYSLIBS)
  52. #SRCDIRS = ":$(SRCDIR)" $(SRCSUBDIRS)
  53. #INCDIRS = ":$(INCDIR):" $(MOREINCDIRS)
  54. ALLREZS = $(MOREREZS) $(REZS)
  55. CC-68K-MW = MWC68K
  56. CC-PPC-MW = MWCPPC        # not tested
  57. CC-68K-SC = SCpp        # not tested
  58. CC-PPC-MrC = MrCpp    # not tested
  59. CC = $(CC-$(ARCH)-$(COMPILER))
  60. DEFS-Release = -d _NO_DEBUGGING
  61. DEFS = $(DEFS-$(BUILD)) $(USERDEFS)
  62. WARN = -w off
  63. # Language options
  64. # We need exceptions, the bool type, and unix-style newline escapes.
  65. # MWC automatically assumes exceptions for C++ files.
  66. # MrC defaults to 'public' template expansion.
  67. CLANG-MW = 
  68. CLANG-MrC = -EH -xa static
  69. CLANG-SC = -EH
  70. CLANG = $(CLANG-$(COMPILER)) -bool on -nomapcr
  71. OPT-Debug = -opt off
  72. OPT-Release = -opt all
  73. OPT = $(OPT-$(BUILD))
  74. CODEGEN-68K = -model far
  75. CODEGEN-PPC = 
  76. CODEGEN = $(CODEGEN-$(ARCH)) -enum int $(OPT)
  77. DEBUGGING-Debug = -sym full
  78. DEBUGGING-Release = -sym off
  79. DEBUGGING = $(DEBUGGING-$(BUILD))
  80. COPTS = $(DEFS) $(WARN) $(CLANG) $(CODEGEN) $(DEBUGGING)
  81. IO-MW = -EOL
  82. IO-MrC = 
  83. IO = $(IO-$(COMPILER))
  84. EXT-MW = -ext o
  85. EXT-MrC = 
  86. EXT = $(EXT-$(COMPILER)) -o $(OBJDIR)
  87. SYSINCTOKEN-MW = -i-
  88. SYSINCTOKEN-SC =
  89. SYSINCTOKEN-MrC =
  90. SYSINCTOKEN = $(SYSINCTOKEN-$(COMPILER))
  91. INC = $(CINCLUDES) $(SYSINCTOKEN) $(CSYSINCLUDES)
  92. CFLAGS = $(COPTS) $(IO) $(EXT) $(INC)
  93. LINKAPP-68K-MW = MWLink68K -xm a
  94. LINKAPP-PPC-MW = MWLinkPPC -xm a
  95. #LINKAPP-68K-SC = ILink  # -csym 'MWDB'
  96. LINKAPP-68K-SC = Link -csym 'MWDB'
  97. LINKAPP-PPC-MrC = PPCLink -xm e
  98. LINKAPPFLAGS-68K = -model far
  99. LINKAPPFLAGS-PPC =
  100. LINKAPPFLAGS = -t 'APPL' -c $(CREATOR) $(LINKAPPFLAGS-$(ARCH))  # -w
  101. LINKAPP = $(LINKAPP-$(ARCH)-$(COMPILER)) $(LINKAPPFLAGS)
  102. LINKLIB-68K-MW = MWLink68K -xm l
  103. LINKLIB-PPC-MW = MWLinkPPC -xm l
  104. LINKLIB-68K-SC = Lib
  105. LINKLIB-PPC-MrC = PPCLink -xm l
  106. LINKLIB = $(LINKLIB-$(ARCH)-$(COMPILER))
  107. LDFLAGS = $(DEBUGGING) -mf
  108. APPNAME = $(NAME)
  109. EXEDIR = $(PROJLABDIR)$(EXEDIRNAME):$(ARCH):$(COMPILER):$(BUILD):
  110. LIBNAME = $(NAME).lib
  111. LIBDIR = $(PROJLABDIR)$(LIBDIRNAME):$(ARCH):$(COMPILER):$(BUILD):
  112. BINARY *= $(MAKETARGET)
  113.  
  114. # The default target.
  115. default : test binary
  116.  
  117. # Used for debugging makefiles.
  118. test :;
  119. #    echo BINARY = '$(BINARY)'
  120.  
  121. # Make the binary file.  Might be app, da, driver, coderes, tool, or lib.
  122. binary : $(BINARY)
  123.  
  124. # Dirs are *always* out of date, because we keep bumping the date on them.
  125. # So we include them in front of (not in) the binary.
  126.  
  127. app : objdir exedir making "$(EXEDIR)$(APPNAME)"
  128.  
  129. lib : objdir libdir making "$(LIBDIR)$(LIBNAME)"
  130.  
  131. # This is a hack to make sure that a failed-to-link app gets updated.
  132. "$(EXEDIR)Doody" :
  133.     Echo -n '' > "$(EXEDIR)Doody"
  134.  
  135. # : $(EXTRAOBJS) 
  136. "$(EXEDIR)$(APPNAME)" : $(OBJS) $(MOREOBJS) $(ALLLIBS) $(ALLREZS) "$(EXEDIR)Doody"
  137.     Echo -n '' > "$(EXEDIR)Doody"
  138.     Echo 'Compiling resources...'
  139.     Echo ">" $(subst,$(QQ), $(ALLREZS:s/ /_|_/:f:s/_|_/ /))
  140.     Rez -a -o $(EXEDIR)$(APPNAME) $(ALLREZS)
  141.     Echo 'Linking...'
  142.     Echo "> $(APPNAME)"
  143.     $(LINKAPP) $(LDFLAGS) -o $(EXEDIR)$(APPNAME) $(ALLLIBS) $(ALLOBJS)
  144.     SetFile -a BM $(EXEDIR)$(APPNAME)
  145.  
  146. "$(LIBDIR)$(LIBNAME)" : $(OBJS)
  147.     Echo 'Linking...'
  148.     Echo '> $(LIBNAME)'
  149.     $(LINKLIB) $(LDFLAGS) -o $(LIBDIR)$(LIBNAME) $(ALLOBJS)
  150. #    PlaySound "Indigo"
  151.  
  152. update : objs
  153.  
  154. # A phony target to compile only.  It reqs a dir, so it's always out of date.
  155. objs : objdir $(OBJS)
  156.  
  157. objdir : "$(PROJLABDIR)$(OBJDIRNAME):" "$(PROJLABDIR)$(OBJDIRNAME):$(ARCH):" "$(PROJLABDIR)$(OBJDIRNAME):$(ARCH):$(COMPILER):" "$(PROJLABDIR)$(OBJDIRNAME):$(ARCH):$(COMPILER):$(BUILD):"
  158. #objdir : "$(PROJLABDIR)$(OBJDIRNAME):$(ARCH):$(BUILD):"
  159. libdir : "$(PROJLABDIR)$(LIBDIRNAME):" "$(PROJLABDIR)$(LIBDIRNAME):$(ARCH):" "$(PROJLABDIR)$(LIBDIRNAME):$(ARCH):$(COMPILER):" "$(PROJLABDIR)$(LIBDIRNAME):$(ARCH):$(COMPILER):$(BUILD):"
  160. exedir : "$(PROJLABDIR)$(EXEDIRNAME):" "$(PROJLABDIR)$(EXEDIRNAME):$(ARCH):" "$(PROJLABDIR)$(EXEDIRNAME):$(ARCH):$(COMPILER):" "$(PROJLABDIR)$(EXEDIRNAME):$(ARCH):$(COMPILER):$(BUILD):"
  161.  
  162. #":%:" : "$(@:d:d)"  # This should work perfectly, but it doesn't.  dmake sucks.
  163. "%:" : "$(@:d:d)"  # This should work perfectly, but it doesn't.  dmake sucks.
  164. #    Echo $$* = $*
  165. #    Echo $$@ = $@
  166. #    Echo $$(@:d:d) = $(@:d:d)
  167.     Echo "Creating the $* directory."
  168.     Echo "> $*"
  169.     NewFolder '$@'
  170.  
  171. %.r : %.rsrc
  172.     Echo "Decompiling '$(<:f)'."
  173.     Echo "> $(@:f)"
  174.     DeRez '$<' > '$@'
  175.  
  176. %.o :| %.cc %.cpp %.cp %.c #
  177. # This stupid hack is required because there may be spaces in the pathname.
  178.     Echo '> $(<:s/ /_|_/:f:s/_|_/ /)'
  179.     $(CC) $(CFLAGS) '$<'
  180. # Ugly hack for MPW compilers that insist on .c.o instead of .o
  181.     If `Exists "$(@:d)$(<:s/ /_|_/:f:s/_|_/ /).o"`
  182.         Rename -y "$(@:d)$(<:s/ /_|_/:f:s/_|_/ /).o" "$(@:b).o"
  183.     End If
  184. #    PlaySound "Droplet"  # This gets annoying real fast
  185.  
  186. making :
  187.     Echo "Compiling... (maybe)"
  188.  
  189. # We don't need to search directories whose files specify them explicitly.
  190. .SOURCE.o : $(OBJDIR)
  191. .SOURCE.lib : ":$(LIBDIR):"
  192.  
  193. .PHONY : test binary app da driver coderes tool lib objdir libdir exedir update objs making
  194.